Skip to content

Add codemod exclusion flags to fix and upgrade#38688

Merged
pelikhan merged 2 commits into
mainfrom
copilot/add-cli-arg-disable-codemods
Jun 11, 2026
Merged

Add codemod exclusion flags to fix and upgrade#38688
pelikhan merged 2 commits into
mainfrom
copilot/add-cli-arg-disable-codemods

Conversation

Copilot AI commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

This adds a way to opt specific codemods out of gh aw fix and gh aw upgrade. The change is scoped to codemod selection: callers can now suppress individual migrations by codemod ID, and invalid IDs fail fast.

  • CLI surface

    • Add repeatable --disable-codemod to gh aw fix
    • Add repeatable --disable-codemod to gh aw upgrade
    • Preserve existing behavior when the flag is not provided
  • Codemod selection

    • Introduce filtered codemod resolution instead of always applying the full registry
    • Exclude only the requested codemod IDs
    • Return a clear error for unknown codemod IDs rather than silently ignoring them
  • Command wiring

    • Thread disabled codemod IDs through FixConfig and the upgrade flow
    • Ensure upgrade passes exclusions into its internal fix step
  • Coverage

    • Add focused tests for:
      • flag registration on both commands
      • codemod filtering behavior
      • unknown-ID rejection
      • end-to-end skip behavior for a disabled codemod

Example:

gh aw fix --write \
  --disable-codemod timeout-minutes-migration \
  --disable-codemod network-firewall-migration

gh aw upgrade \
  --disable-codemod serena-tools-to-shared-import

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title Add disable-codemod flags to fix and upgrade Add codemod exclusion flags to fix and upgrade Jun 11, 2026
Copilot AI requested a review from pelikhan June 11, 2026 17:51
@pelikhan pelikhan marked this pull request as ready for review June 11, 2026 17:54
Copilot AI review requested due to automatic review settings June 11, 2026 17:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a user-facing mechanism to exclude specific codemods by ID when running gh aw fix and the internal fix step within gh aw upgrade, including validation that unknown codemod IDs produce an error.

Changes:

  • Add repeatable --disable-codemod flag to both fix and upgrade commands and thread disabled IDs through config/options.
  • Introduce GetCodemods(disabledIDs) to filter the codemod registry and reject unknown IDs.
  • Add unit tests covering flag registration, filtering behavior, unknown-ID errors, and an end-to-end skip case.
Show a summary per file
File Description
pkg/cli/upgrade_command.go Adds --disable-codemod to upgrade and passes disabled codemod IDs into the fix step config.
pkg/cli/upgrade_command_test.go Asserts the new --disable-codemod flag is registered and described in help text.
pkg/cli/fix_command.go Adds --disable-codemod to fix and switches codemod loading from GetAllCodemods() to filtered GetCodemods(...).
pkg/cli/fix_command_test.go Adds tests for flag registration and an end-to-end “disabled codemod is skipped” scenario.
pkg/cli/fix_codemods.go Implements GetCodemods(...) filtering + unknown-ID validation.
pkg/cli/fix_codemods_test.go Adds tests for disable filtering and unknown-ID error behavior.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 6/6 changed files
  • Comments generated: 1

Comment thread pkg/cli/upgrade_command.go
@pelikhan pelikhan merged commit 3ca1559 into main Jun 11, 2026
30 checks passed
@pelikhan pelikhan deleted the copilot/add-cli-arg-disable-codemods branch June 11, 2026 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants